#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton* button = new QPushButton(this);
    button->setText("button");
    button->move(100,100);
    button->setEnabled(false);
    connect(button,&QPushButton::clicked,this,[=](){
        button->setText("clicked");
        this->setWindowTitle("click");
    });
    connect(ui->pushButton_target,&QPushButton::clicked,this,[=](){
        if(button->isEnabled())
            button->setEnabled(false);
        else
            button->setEnabled(true);
        qDebug()<<"enble chang";
    });
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_up_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    qDebug()<<rect;
//    rect.setY(rect.y()-5);
//    ui->pushButton_target->setGeometry(rect);
    ui->pushButton_target->setGeometry(rect.x(),rect.y()-5,rect.width(),rect.height());
}

void Widget::on_down_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    qDebug()<<rect;
//    rect.setY(rect.y()+5);
//    ui->pushButton_target->setGeometry(rect);
    ui->pushButton_target->setGeometry(rect.x(),rect.y()+5,rect.width(),rect.height());

}

void Widget::on_left_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    qDebug()<<rect;
//    rect.setX(rect.x()-5);
//    ui->pushButton_target->setGeometry(rect);
    ui->pushButton_target->setGeometry(rect.x()-5,rect.y(),rect.width(),rect.height());
}

void Widget::on_right_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    qDebug()<<rect;
//    rect.setX(rect.x()+5);
//    ui->pushButton_target->setGeometry(rect);
    ui->pushButton_target->setGeometry(rect.x()+5,rect.y(),rect.width(),rect.height());
}
